# -*- coding: UTF-8 -*-
# server_assets
# @File : stateBuffer.py
# @Date : 2023-08-29
# @Author  : wuzhouhai
# @Desc:
import KBEngine
from KBEDebug import *

import s_skillBuff


class StateBuffer:
    """Buff 状态
    """

    def __init__(self, buffID, holder=0, executor=0, skillHurt=0):
        """
        Constructor
        @param buffID: int buff的ID
        """
        self.id = buffID  # buff的ID
        self.stack = 1  # buff的层叠数
        self.traceCD = 0  # 剩余的回合数
        self.executor = executor  # buff施加者的战场id
        self.holder = holder  # 持有者的战场id
        self.format = {}  # buff的详细信息
        self.effectFormat = {}  # buff效果的详细信息
        self.remainLife = 0  # BUFF剩余生命值,针对减伤类BUFF
        self.effectId = 0
        self.skillHurt = skillHurt  # 技能威力
        self.skillArmor = 0  # buff护甲值
        self.initBuffInfo()  # 初始化buff的信息

    def initBuffInfo(self):
        """初始化buff信息"""
        if self.id not in s_skillBuff.datas.keys():
            return
        self.format = s_skillBuff.datas[self.id]
        self.traceCD = self.format['surviceTraceCD']

    def getID(self):
        """获取Buff的id"""
        return self.id

    def getName(self):
        """获取buff名称"""
        return self.format['buffName']

    def getExecutor(self):
        """获取施加者的战场id"""
        return self.executor

    def getSkillHurt(self):
        """获取技能威力"""
        return self.skillHurt

    def getMainType(self):
        """获取BUFF主类型"""
        return self.format['mainType']

    def getSubType(self):
        """获取BUFF子类型"""
        return self.format['subType']

    def getAttType(self):
        """获取BUFF关联属性类型"""
        return self.format['attType']

    def getStack(self):
        """获取buff的当前堆叠数"""
        return self.stack

    def addStack(self):
        """添加一层堆叠"""
        self.traceCD = self.format['surviceTraceCD']
        if self.stack >= self.getMaxStack():
            return
        self.stack += 1

    def getTraceCD(self):
        """获取剩下回合数"""
        return self.traceCD

    def cutTraceCD(self):
        """剪掉一次回合数"""
        self.traceCD -= 1
        return self.traceCD

    def getMaxStack(self):
        """获取buff的最大堆叠数"""
        return self.format['maxStack']

    def getValueType(self):
        """获取BUFF数值类型"""
        return self.format['valueType']

    def getValue(self):
        """获取BUFF数值"""
        return self.format['value']

    def getSpecialValue(self):
        """获取BUFF特殊数值"""
        return self.format['specialValue']

    def getTargetType(self):
        """获取BUFF目标类型"""
        return self.format['targetType']
